<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>测试网页和原生通信</title>
    <style>
        .avatar {
            width: 300px;
            height: 300px;
            border-radius: 50%;
        }
    </style>
</head>

<body>
    <h1>测试通信</h1>
    <button id="btn1">测试弹出</button>
    <button id="btnPhoto">拍照</button>
    <button id="btnSelect">选择相册</button>
    <img class="avatar" src="" alt="">
    <!-- 引入调试控制台 -->
    <script src="./eruda.js"></script>
    <script>eruda.init();</script>
    <script>
        document.querySelector("#btn1").addEventListener("click", () => {
            // window.whh.showMessage("我成功了")
            const user = whh.getUser() // 获取用户信息
            whh.showMessage(JSON.stringify(user)) // 弹出消息
        })

        function changeH1(name) {
            document.querySelector("h1").innerText = name
        }
        document.querySelector("#btnPhoto").addEventListener("click", async () => {
            const url = await whh.takePicture()
            document.querySelector(".avatar").src = url
        })
        document.querySelector("#btnSelect").addEventListener("click", async () => {
            const url = await whh.selectPicture()
            document.querySelector(".avatar").src = url
        })


    </script>
</body>

</html>